/* This replication code works on the following datasets:
1. A pseudo dataset:  multivariate_pseudo_sample.dta (Stata data)
2. A pseudo dataset:  tfp_long_term_pseudo (Stata data)
*/

cap n clear
cap n clear matrix
cd "X:\your_directory"

/**********************************************************************************/
/*********** Table 2 Summary stats ****************************************/
/**********************************************************************************/

use multivariate_pseudo_sample, clear
drop if public==1

set more off
global control tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics vcfracst vcfracnaic3 hind

reg exit $control i.year if late!=. & naics3!=.
keep if e(sample)

bysort year: egen rd_naicsh3_mean=mean(rd_naicsh3)
replace rd_naicsh3=rd_naicsh3_mean if missing(rd_naicsh3)
gen lnnregion=log(1+numregionfed_lrd)
gen outregion=1-inregion_fed
winsor2 rd_naicsh3 outregion lnnregion, replace

putexcel set "X:\your_directory\Table2.xlsx", sheet(SumStats) replace
putexcel A1=("Variable") B1=("N") C1=("mean") D1=("sd")

local row=2

foreach var in ipo ma late tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics lnnregion rd_naicsh3 outregion hind vcfracst vcfracnaic3 {
	qui sum `var', det
putexcel A`row' = ("`var'")
putexcel B`row' = (r(N))
putexcel C`row' = (r(mean))
putexcel D`row' = (r(sd))
local ++row
}
/* Note: the order of the above variables corresponds to the order that they show up in Table 2, so although some var names may look slightly diff from their counterparts in Table 2, it should be straightforward to map them one by one. */

/**********************************************************************************/
/****** Table 3 Mlogit models for pre2000 and post2000 subsamples separately *********/
/**********************************************************************************/

use multivariate_pseudo_sample, clear
drop if public==1

set more off
global control tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics vcfracst vcfracnaic3 hind

reg exit $control i.year if late!=. & naics3!=.
keep if e(sample)

bysort year: egen rd_naicsh3_mean=mean(rd_naicsh3)
replace rd_naicsh3=rd_naicsh3_mean if missing(rd_naicsh3)
gen lnnregion=log(1+numregionfed_lrd)
gen outregion=1-inregion_fed
winsor2 rd_naicsh3 outregion lnnregion, replace

xi: mlogit exit tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics rd_naicsh3 outregion hind vcfracst vcfracnaic3 i.year if late==0, base(0) vce(cluster naics3)

xi: mlogit exit tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics rd_naicsh3 outregion hind vcfracst vcfracnaic3 i.year if late==1, base(0) vce(cluster naics3)

xi: mlogit exit tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnregion rd_naicsh3 outregion hind vcfracst vcfracnaic3 i.year if late==0, base(0) vce(cluster naics3)
predict prob_ipo_mlogit_early, pr outcome(2)
predict prob_ma_mlogit_early, pr outcome(1)
predict prob_prv_mlogit_early, pr outcome(0)

xi: mlogit exit tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnregion rd_naicsh3 outregion hind vcfracst vcfracnaic3 i.year if late==1, base(0) vce(cluster naics3)
predict prob_ipo_mlogit_late, pr outcome(2)
predict prob_ma_mlogit_late, pr outcome(1)
predict prob_prv_mlogit_late, pr outcome(0)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the actual estimated probability for IPO in early years */
sum prob_ipo_mlogit_early if late==0, d 
/* The following is the hypothetical estimated probability for IPO in late years using early-year firm characteristics! */
sum prob_ipo_mlogit_late if late==0, d 
ttest prob_ipo_mlogit_early == prob_ipo_mlogit_late if late==0

/***********************************************************************************/
/***************** Multinomial Logit ACQ probabilities */
/* The following is the actual estimated probability for ACQ in early years */
sum prob_ma_mlogit_early if late==0, d 
/* The following is the hypothetical estimated probability for ACQ in late years using early-year firm characteristics! */
sum prob_ma_mlogit_late if late==0, d 
ttest prob_ma_mlogit_early == prob_ma_mlogit_late if late==0

************************************************************************************************
/* Table 4: TFP analysis */ 
************************************************************************************************

use multivariate_pseudo_sample, clear
drop if public==1

set more off
global control tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics vcfracst vcfracnaic3 hind

reg exit $control i.year if late!=. & naics3!=.
keep if e(sample)

bysort year: egen rd_naicsh3_mean=mean(rd_naicsh3)
replace rd_naicsh3=rd_naicsh3_mean if missing(rd_naicsh3)
gen lnnregion=log(1+numregionfed_lrd)
gen outregion=1-inregion_fed
winsor2 rd_naicsh3 outregion lnnregion, replace

gen ipo_late=ipo*late
gen ma_late=ma*late

global control1 lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics rd_naicsh3 outregion hind vcfracst vcfracnaic3
global control2 lnsales lnage capint capexratio mktshr whiteprop vc lnnregion rd_naicsh3 outregion hind vcfracst vcfracnaic3
global control3 lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics outregion vcfracst
global control4 lnsales lnage capint capexratio mktshr whiteprop vc lnnregion outregion vcfracst

reghdfe tfp ipo_late ipo ma_late ma $control1, a(year) cluster(naics3) keepsingleton
test ipo_late=ma_late

reghdfe tfp ipo_late ipo ma_late ma $control2, a(year) cluster(naics3) keepsingleton
test ipo_late=ma_late

reghdfe tfp ipo_late ipo ma_late ma $control1, a(naics3 year) cluster(naics3) keepsingleton
test ipo_late=ma_late

reghdfe tfp ipo_late ipo ma_late ma $control2, a(naics3 year) cluster(naics3) keepsingleton
test ipo_late=ma_late

reghdfe tfp ipo_late ipo ma_late ma $control3, a(naics3#year) cluster(naics3) keepsingleton
test ipo_late=ma_late

reghdfe tfp ipo_late ipo ma_late ma $control4, a(naics3#year) cluster(naics3) keepsingleton
test ipo_late=ma_late

************************************************************************************************
/* Table 5: Mlogit analysis with interaction terms involving the late dummy*/ 
************************************************************************************************

use multivariate_pseudo_sample, clear
drop if public==1

set more off
global control tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics vcfracst vcfracnaic3 hind

reg exit $control i.year if late!=. & naics3!=.
keep if e(sample)

bysort year: egen rd_naicsh3_mean=mean(rd_naicsh3)
replace rd_naicsh3=rd_naicsh3_mean if missing(rd_naicsh3)
gen lnnregion=log(1+numregionfed_lrd)
gen outregion=1-inregion_fed
winsor2 rd_naicsh3 outregion lnnregion, replace

foreach var of varlist tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics lnnregion rd_naicsh3 outregion hind vcfracst vcfracnaic3 {
	gen `var'_late=late*`var'
}

global control_late1 tfp_late lnsales_late lnage_late capint_late capexratio_late mktshr_late whiteprop_late vc_late lnnnaics_late rd_naicsh3_late outregion_late hind_late vcfracst_late vcfracnaic3_late tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics rd_naicsh3 outregion hind vcfracst vcfracnaic3

global control_late2 tfp_late lnsales_late lnage_late capint_late capexratio_late mktshr_late whiteprop_late vc_late lnnregion_late rd_naicsh3_late outregion_late hind_late vcfracst_late vcfracnaic3_late tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnregion rd_naicsh3 outregion hind vcfracst vcfracnaic3

xi: mlogit exit $control_late1 i.year, base(0) vce(cluster naics3)

xi: mlogit exit $control_late2 i.year, base(0) vce(cluster naics3)

************************************************************************************************
/* Table 6: post-exit long-term TFP for IPO and matched private firms */ 
************************************************************************************************

use tfp_long_term_pseudo, clear

set more off
global control lnsales lnage capint capexratio mktshr whiteprop lnnnaics lnnregion

reghdfe next3_tfp ipo_late ipo $control if vc_sample==1, a(ipo_match_group year) cluster(naics3)
reghdfe next3_tfp ipo_late ipo $control if vc_sample==0, a(ipo_match_group year) cluster(naics3)

reghdfe next2_tfp ipo_late ipo $control if vc_sample==1, a(ipo_match_group year) cluster(naics3)
reghdfe next2_tfp ipo_late ipo $control if vc_sample==0, a(ipo_match_group year) cluster(naics3)

************************************************************************************************
/* Table 7: Subsample DiD tests */ 
************************************************************************************************

use multivariate_pseudo_sample, clear
drop if public==1

set more off
global control tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnnaics vcfracst vcfracnaic3 hind

reg exit $control i.year if late!=. & naics3!=.
keep if e(sample)

bysort year: egen rd_naicsh3_mean=mean(rd_naicsh3)
replace rd_naicsh3=rd_naicsh3_mean if missing(rd_naicsh3)
gen lnnregion=log(1+numregionfed_lrd)
gen outregion=1-inregion_fed
winsor2 rd_naicsh3 outregion lnnregion, replace

gen singleseg=1
replace singleseg=0 if lnnnaics>0
gen singleregion=1
replace singleregion=0 if numregionfed_lrd>1

bysort year: egen hind_median=median(hind)
gen highhind=0
replace highhind=1 if hind>=hind_median

bysort year: egen vcfracst_median=median(vcfracst)
gen highvcst=0
replace highvcst=1 if vcfracst>=vcfracst_median

bysort year: egen vcfracnaic3_median=median(vcfracnaic3)
gen highvcnaics3=0
replace highvcnaics3=1 if vcfracnaic3>=vcfracnaic3_median

bysort year: egen rd_naicsh3_median=median(rd_naicsh3)
gen highrd=0
replace highrd=1 if rd_naicsh3>=rd_naicsh3_median

bysort year: egen outregion_median=median(outregion)
gen highoutregion=0
replace highoutregion=1 if outregion>=outregion_median

global control tfp lnsales lnage capint capexratio mktshr whiteprop vc lnnregion rd_naicsh3 outregion hind vcfracst vcfracnaic3

/******************************************************************/
/***************** Panel A: Single/Multi-segment Firms  *********************************************/

xi: mlogit exit $control i.year if late==0 & singleseg ==1, base(0)  
predict prob_ipo_mlogit_early_singleseg , pr outcome(2)
predict prob_ma_mlogit_early_singleseg , pr outcome(1)
xi: mlogit exit $control i.year if late==1 & singleseg ==1, base(0)  
predict prob_ipo_mlogit_late_singleseg , pr outcome(2)
predict prob_ma_mlogit_late_singleseg , pr outcome(1)
xi: mlogit exit $control i.year if late==0 & singleseg ==0, base(0)  
predict prob_ipo_mlogit_early_Nsingleseg , pr outcome(2)
predict prob_ma_mlogit_early_Nsingleseg , pr outcome(1)
xi: mlogit exit $control i.year if late==1 & singleseg ==0, base(0)  
predict prob_ipo_mlogit_late_Nsingleseg , pr outcome(2)
predict prob_ma_mlogit_late_Nsingleseg , pr outcome(1)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the actual estimated probability for IPO in early years for singleseg  */
sum prob_ipo_mlogit_early_singleseg  if late==0 & singleseg ==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for singleseg  using early-year singleseg  firm characteristics! */
sum prob_ipo_mlogit_late_singleseg  if late==0 & singleseg ==1, d 
ttest prob_ipo_mlogit_early_singleseg == prob_ipo_mlogit_late_singleseg if late==0 & singleseg==1
/* The following is the hypothetical estimated probability for IPO in early years for Nsingleseg  using early-year singleseg  firm characteristics! */
sum prob_ipo_mlogit_early_Nsingleseg  if late==0 & singleseg ==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nsingleseg  using early-year singleseg  firm characteristics! */
sum prob_ipo_mlogit_late_Nsingleseg  if late==0 & singleseg ==1, d 
ttest prob_ipo_mlogit_early_Nsingleseg == prob_ipo_mlogit_late_Nsingleseg if late==0 & singleseg==1
/* Diff in diff t-test */
gen prob_ipo_mlogit_singleseg_diff=prob_ipo_mlogit_late_singleseg-prob_ipo_mlogit_early_singleseg if late==0
gen prob_ipo_mlogit_Nsingleseg_diff=prob_ipo_mlogit_late_Nsingleseg-prob_ipo_mlogit_early_Nsingleseg if late==0
ttest prob_ipo_mlogit_singleseg_diff == prob_ipo_mlogit_Nsingleseg_diff if late==0 & singleseg==1

/***********************************************************************************/
/***************** Multinomial Logit ma probabilities */
/* The following is the actual estimated probability for ma in early years for singleseg  */
sum prob_ma_mlogit_early_singleseg  if late==0 & singleseg ==1, d 
/* The following is the hypothetical estimated probability for ma in late years for singleseg  using early-year singleseg  firm characteristics! */
sum prob_ma_mlogit_late_singleseg  if late==0 & singleseg ==1, d 
ttest prob_ma_mlogit_early_singleseg == prob_ma_mlogit_late_singleseg if late==0 & singleseg==1
/* The following is the hypothetical estimated probability for ma in early years for Nsingleseg  using early-year singleseg  firm characteristics! */
sum prob_ma_mlogit_early_Nsingleseg  if late==0 & singleseg ==1, d 
/* The following is the hypothetical estimated probability for ma in late years for Nsingleseg  using early-year singleseg  firm characteristics! */
sum prob_ma_mlogit_late_Nsingleseg  if late==0 & singleseg ==1, d 
ttest prob_ma_mlogit_early_Nsingleseg == prob_ma_mlogit_late_Nsingleseg if late==0 & singleseg==1
/* Diff in diff t-test */
gen prob_ma_mlogit_singleseg_diff=prob_ma_mlogit_late_singleseg-prob_ma_mlogit_early_singleseg if late==0
gen prob_ma_mlogit_Nsingleseg_diff=prob_ma_mlogit_late_Nsingleseg-prob_ma_mlogit_early_Nsingleseg if late==0
ttest prob_ma_mlogit_singleseg_diff == prob_ma_mlogit_Nsingleseg_diff if late==0 & singleseg==1

/******************************************************************/
/***************** Panel B: Single/Multi-region Firms  *********************************************/

xi: mlogit exit $control i.year if late==0 & singleregion ==1, base(0)  
predict prob_ipo_mlogit_early_singlergn , pr outcome(2)
predict prob_ma_mlogit_early_singlergn , pr outcome(1)
xi: mlogit exit $control i.year if late==1 & singleregion ==1, base(0)  
predict prob_ipo_mlogit_late_singlergn , pr outcome(2)
predict prob_ma_mlogit_late_singlergn , pr outcome(1)
xi: mlogit exit $control i.year if late==0 & singleregion ==0, base(0)  
predict prob_ipo_mlogit_early_Nsinglergn , pr outcome(2)
predict prob_ma_mlogit_early_Nsinglergn , pr outcome(1)
xi: mlogit exit $control i.year if late==1 & singleregion ==0, base(0)  
predict prob_ipo_mlogit_late_Nsinglergn , pr outcome(2)
predict prob_ma_mlogit_late_Nsinglergn , pr outcome(1)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the actual estimated probability for IPO in early years for singleregion  */
sum prob_ipo_mlogit_early_singlergn  if late==0 & singleregion ==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for singleseg  using early-year singleregion  firm characteristics! */
sum prob_ipo_mlogit_late_singlergn  if late==0 & singleregion ==1, d 
ttest prob_ipo_mlogit_early_singlergn == prob_ipo_mlogit_late_singlergn if late==0 & singleregion==1
/* The following is the hypothetical estimated probability for IPO in early years for Nsingleregion  using early-year singleregion firm characteristics! */
sum prob_ipo_mlogit_early_Nsinglergn  if late==0 & singleregion ==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nsingleregion  using early-year singleregion  firm characteristics! */
sum prob_ipo_mlogit_late_Nsinglergn  if late==0 & singleregion ==1, d 
ttest prob_ipo_mlogit_early_Nsinglergn == prob_ipo_mlogit_late_Nsinglergn if late==0 & singleregion==1
/* Diff in diff t-test */
gen prob_ipo_mlogit_singlergn_diff=prob_ipo_mlogit_late_singlergn-prob_ipo_mlogit_early_singlergn if late==0
gen prob_ipo_mlogit_Nsinglergn_diff=prob_ipo_mlogit_late_Nsinglergn-prob_ipo_mlogit_early_Nsinglergn if late==0
ttest prob_ipo_mlogit_singlergn_diff == prob_ipo_mlogit_Nsinglergn_diff if late==0 & singleregion==1

/***********************************************************************************/
/***************** Multinomial Logit ma probabilities */
/* The following is the actual estimated probability for IPO in early years for singleregion  */
sum prob_ma_mlogit_early_singlergn  if late==0 & singleregion ==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for singleregion  using early-year singleregion  firm characteristics! */
sum prob_ma_mlogit_late_singlergn  if late==0 & singleregion ==1, d 
ttest prob_ma_mlogit_early_singlergn == prob_ma_mlogit_late_singlergn if late==0 & singleregion==1
/* The following is the hypothetical estimated probability for IPO in early years for Nsingleregion  using early-year singleregion firm characteristics! */
sum prob_ma_mlogit_early_Nsinglergn  if late==0 & singleregion ==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nsingleregion using early-year singleregion firm characteristics! */
sum prob_ma_mlogit_late_Nsinglergn  if late==0 & singleregion ==1, d 
ttest prob_ma_mlogit_early_Nsinglergn == prob_ma_mlogit_late_Nsinglergn if late==0 & singleregion==1
/* Diff in diff t-test */
gen prob_ma_mlogit_singlergn_diff=prob_ma_mlogit_late_singlergn-prob_ma_mlogit_early_singlergn if late==0
gen prob_ma_mlogit_Nsinglergn_diff=prob_ma_mlogit_late_Nsinglergn-prob_ma_mlogit_early_Nsinglergn if late==0
ttest prob_ma_mlogit_singlergn_diff == prob_ma_mlogit_Nsinglergn_diff if late==0 & singleregion==1

/******************************************************************/
/*****************  Panel C: High/Low NonLocalComp Firms *********************************************/

xi: mlogit exit $control outregion i.year if late==0 & highoutregion==1, base(0) iter(20)
predict prob_ipo_mlogit_early_highcomp, pr outcome(2)
predict prob_ma_mlogit_early_highcomp, pr outcome(1)
xi: mlogit exit $control outregion i.year if late==1 & highoutregion==1, base(0)  
predict prob_ipo_mlogit_late_highcomp, pr outcome(2)
predict prob_ma_mlogit_late_highcomp, pr outcome(1)
xi: mlogit exit $control outregion i.year if late==0 & highoutregion==0, base(0) iter(20)
predict prob_ipo_mlogit_early_Nhighcomp, pr outcome(2)
predict prob_ma_mlogit_early_Nhighcomp, pr outcome(1)
xi: mlogit exit $control outregion i.year if late==1 & highoutregion==0, base(0)  
predict prob_ipo_mlogit_late_Nhighcomp, pr outcome(2)
predict prob_ma_mlogit_late_Nhighcomp, pr outcome(1)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the actual estimated probability for IPO in early years for highoutregion */
sum prob_ipo_mlogit_early_highcomp if late==0 & highoutregion==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for highoutregion using early-year highoutregion firm characteristics! */
sum prob_ipo_mlogit_late_highcomp if late==0 & highoutregion==1, d 
ttest prob_ipo_mlogit_early_highcomp == prob_ipo_mlogit_late_highcomp if late==0 & highoutregion==1
/* The following is the hypothetical estimated probability for IPO in early years for Nhighoutregion using early-year highoutregion firm characteristics! */
sum prob_ipo_mlogit_early_Nhighcomp if late==0 & highoutregion==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nhighoutregion using early-year highoutregion firm characteristics! */
sum prob_ipo_mlogit_late_Nhighcomp if late==0 & highoutregion==1, d 
ttest prob_ipo_mlogit_early_Nhighcomp == prob_ipo_mlogit_late_Nhighcomp if late==0 & highoutregion==1
/* Diff in diff t-test */
gen prob_ipo_mlogit_highcomp_diff=prob_ipo_mlogit_late_highcomp-prob_ipo_mlogit_early_highcomp if late==0
gen prob_ipo_mlogit_Nhighcomp_diff=prob_ipo_mlogit_late_Nhighcomp-prob_ipo_mlogit_early_Nhighcomp if late==0
ttest prob_ipo_mlogit_Nhighcomp_diff == prob_ipo_mlogit_highcomp_diff if late==0 & highoutregion==1

/***********************************************************************************/
/***************** Multinomial Logit ma probabilities */
/* The following is the actual estimated probability for IPO in early years for highoutregion */
sum prob_ma_mlogit_early_highcomp if late==0 & highoutregion==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for highhind using early-year highoutregion firm characteristics! */
sum prob_ma_mlogit_late_highcomp if late==0 & highoutregion==1, d 
ttest prob_ma_mlogit_early_highcomp == prob_ma_mlogit_late_highcomp if late==0 & highoutregion==1
/* The following is the hypothetical estimated probability for IPO in early years for Nhighoutregion using early-year highoutregion firm characteristics! */
sum prob_ma_mlogit_early_Nhighcomp if late==0 & highoutregion==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nhighoutregion using early-year highoutregion firm characteristics! */
sum prob_ma_mlogit_late_Nhighcomp if late==0 & highoutregion==1, d 
ttest prob_ma_mlogit_early_Nhighcomp == prob_ma_mlogit_late_Nhighcomp if late==0 & highoutregion==1
/* Diff in diff t-test */
gen prob_ma_mlogit_highcomp_diff=prob_ma_mlogit_late_highcomp-prob_ma_mlogit_early_highcomp if late==0
gen prob_ma_mlogit_Nhighcomp_diff=prob_ma_mlogit_late_Nhighcomp-prob_ma_mlogit_early_Nhighcomp if late==0
ttest prob_ma_mlogit_Nhighcomp_diff == prob_ma_mlogit_highcomp_diff if late==0 & highoutregion==1

/******************************************************************/
/***************** Panel D: High/Low RDInd Firms *********************************************/

xi: mlogit exit $control i.year if late==0 & highrd==1, base(0)  
predict prob_ipo_mlogit_early_highrd, pr outcome(2)
predict prob_ma_mlogit_early_highrd, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highrd==1, base(0)  
predict prob_ipo_mlogit_late_highrd, pr outcome(2)
predict prob_ma_mlogit_late_highrd, pr outcome(1)
xi: mlogit exit $control i.year if late==0 & highrd==0, base(0)  
predict prob_ipo_mlogit_early_Nhighrd, pr outcome(2)
predict prob_ma_mlogit_early_Nhighrd, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highrd==0, base(0)  
predict prob_ipo_mlogit_late_Nhighrd, pr outcome(2)
predict prob_ma_mlogit_late_Nhighrd, pr outcome(1)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the actual estimated probability for IPO in early years for highrd */
sum prob_ipo_mlogit_early_highrd if late==0 & highrd==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for highrd using early-year highrd firm characteristics! */
sum prob_ipo_mlogit_late_highrd if late==0 & highrd==1, d 
ttest prob_ipo_mlogit_early_highrd == prob_ipo_mlogit_late_highrd if late==0 & highrd==1
/* The following is the hypothetical estimated probability for IPO in early years for Nhighrd using early-year highrd firm characteristics! */
sum prob_ipo_mlogit_early_Nhighrd if late==0 & highrd==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nhighrd using early-year highrd firm characteristics! */
sum prob_ipo_mlogit_late_Nhighrd if late==0 & highrd==1, d 
ttest prob_ipo_mlogit_early_Nhighrd == prob_ipo_mlogit_late_Nhighrd if late==0 & highrd==1
/* Diff in diff t-test */
gen prob_ipo_mlogit_highrd_diff=prob_ipo_mlogit_late_highrd-prob_ipo_mlogit_early_highrd if late==0
gen prob_ipo_mlogit_Nhighrd_diff=prob_ipo_mlogit_late_Nhighrd-prob_ipo_mlogit_early_Nhighrd if late==0
ttest prob_ipo_mlogit_highrd_diff == prob_ipo_mlogit_Nhighrd_diff if late==0 & highrd==1

/***********************************************************************************/
/***************** Multinomial Logit ma probabilities */
/* The following is the actual estimated probability for IPO in early years for highrd */
sum prob_ma_mlogit_early_highrd if late==0 & highrd==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for highrd using early-year highrd firm characteristics! */
sum prob_ma_mlogit_late_highrd if late==0 & highrd==1, d 
ttest prob_ma_mlogit_early_highrd == prob_ma_mlogit_late_highrd if late==0 & highrd==1
/* The following is the hypothetical estimated probability for IPO in early years for Nhighrd using early-year highrd firm characteristics! */
sum prob_ma_mlogit_early_Nhighrd if late==0 & highrd==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nhighrd using early-year highrd firm characteristics! */
sum prob_ma_mlogit_late_Nhighrd if late==0 & highrd==1, d 
ttest prob_ma_mlogit_early_Nhighrd == prob_ma_mlogit_late_Nhighrd if late==0 & highrd==1
/* Diff in diff t-test */
gen prob_ma_mlogit_highrd_diff=prob_ma_mlogit_late_highrd-prob_ma_mlogit_early_highrd if late==0
gen prob_ma_mlogit_Nhighrd_diff=prob_ma_mlogit_late_Nhighrd-prob_ma_mlogit_early_Nhighrd if late==0
ttest prob_ma_mlogit_highrd_diff == prob_ma_mlogit_Nhighrd_diff if late==0 & highrd==1

/******************************************************************/
/***************** Panel E: High/Low HHI Firms  *********************************************/

xi: mlogit exit $control i.year if late==0 & highhind==1, base(0) iter(20)
predict prob_ipo_mlogit_early_hind1, pr outcome(2)
predict prob_ma_mlogit_early_hind1, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highhind==1, base(0)  
predict prob_ipo_mlogit_late_hind1, pr outcome(2)
predict prob_ma_mlogit_late_hind1, pr outcome(1)
xi: mlogit exit $control i.year if late==0 & highhind==0, base(0) iter(20)
predict prob_ipo_mlogit_early_Nhind1, pr outcome(2)
predict prob_ma_mlogit_early_Nhind1, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highhind==0, base(0)  
predict prob_ipo_mlogit_late_Nhind1, pr outcome(2)
predict prob_ma_mlogit_late_Nhind1, pr outcome(1)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the hypothetical estimated probability for IPO in early years for highhind using early-year Nhighhind chara */
sum prob_ipo_mlogit_early_hind1 if late==0 & highhind==0, d 
/* The following is the hypothetical estimated probability for IPO in late years for highhind using early-year Nhighhind firm characteristics! */
sum prob_ipo_mlogit_late_hind1 if late==0 & highhind==0, d 
ttest prob_ipo_mlogit_early_hind1 == prob_ipo_mlogit_late_hind1 if late==0 & highhind==0
/* The following is the actual probability for IPO in early years for Nhighhind using early-year Nhighhind firm characteristics! */
sum prob_ipo_mlogit_early_Nhind1 if late==0 & highhind==0, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nhighhind using early-year Nhighhind firm characteristics! */
sum prob_ipo_mlogit_late_Nhind1 if late==0 & highhind==0, d 
ttest prob_ipo_mlogit_early_Nhind1 == prob_ipo_mlogit_late_Nhind1 if late==0 & highhind==0
/* Diff in diff t-test */
gen prob_ipo_mlogit_hind1_diff=prob_ipo_mlogit_late_hind1-prob_ipo_mlogit_early_hind1 if late==0
gen prob_ipo_mlogit_Nhind1_diff=prob_ipo_mlogit_late_Nhind1-prob_ipo_mlogit_early_Nhind1 if late==0
ttest prob_ipo_mlogit_Nhind1_diff == prob_ipo_mlogit_hind1_diff if late==0 & highhind==0

/***********************************************************************************/
/***************** Multinomial Logit ma probabilities */
/* The following is the hypo estimated probability for ma in early years for highhind  using Nhighhind chara*/
sum prob_ma_mlogit_early_hind1 if late==0 & highhind==0, d 
/* The following is the hypothetical estimated probability for ma in late years for highhind using early-year Nhighhind firm characteristics! */
sum prob_ma_mlogit_late_hind1 if late==0 & highhind==0, d 
ttest prob_ma_mlogit_early_hind1 == prob_ma_mlogit_late_hind1 if late==0 & highhind==0
/* The following is the actaul estimated probability for ma in early years for Nhighhind using early-year Nhighhind firm characteristics! */
sum prob_ma_mlogit_early_Nhind1 if late==0 & highhind==0, d 
/* The following is the hypothetical estimated probability for ma in late years for Nhighhind using early-year Nhighhindfirm characteristics! */
sum prob_ma_mlogit_late_Nhind1 if late==0 & highhind==0, d 
ttest prob_ma_mlogit_early_Nhind1 == prob_ma_mlogit_late_Nhind1 if late==0 & highhind==0
/* Diff in diff t-test */
gen prob_ma_mlogit_hind1_diff=prob_ma_mlogit_late_hind1-prob_ma_mlogit_early_hind1 if late==0
gen prob_ma_mlogit_Nhind1_diff=prob_ma_mlogit_late_Nhind1-prob_ma_mlogit_early_Nhind1 if late==0
ttest prob_ma_mlogit_Nhind1_diff == prob_ma_mlogit_hind1_diff if late==0 & highhind==0

/******************************************************************/
/***************** Panel F: High/Low VCFracSt Firms *********************************************/

xi: mlogit exit $control i.year if late==0 & highvcst==1, base(0)  
predict prob_ipo_mlogit_early_highvcst, pr outcome(2)
predict prob_ma_mlogit_early_highvcst, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highvcst==1, base(0)  
predict prob_ipo_mlogit_late_highvcst, pr outcome(2)
predict prob_ma_mlogit_late_highvcst, pr outcome(1)
xi: mlogit exit $control i.year if late==0 & highvcst==0, base(0)  
predict prob_ipo_mlogit_early_Nhighvcst, pr outcome(2)
predict prob_ma_mlogit_early_Nhighvcst, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highvcst==0, base(0)  
predict prob_ipo_mlogit_late_Nhighvcst, pr outcome(2)
predict prob_ma_mlogit_late_Nhighvcst, pr outcome(1)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the actual estimated probability for IPO in early years for highvc_st_1_LRD */
sum prob_ipo_mlogit_early_highvcst if late==0 & highvcst==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for highvc_st_1_LRD using early-year highvc_st_1_LRD firm characteristics! */
sum prob_ipo_mlogit_late_highvcst if late==0 & highvcst==1, d 
ttest prob_ipo_mlogit_early_highvcst == prob_ipo_mlogit_late_highvcst if late==0 & highvcst==1
/* The following is the hypothetical estimated probability for IPO in early years for Nhighvc_st_1_LRD using early-year highvc_st_1_LRD firm characteristics! */
sum prob_ipo_mlogit_early_Nhighvcst if late==0 & highvcst==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nhighvc_st_1_LRD using early-year highvc_st_1_LRD firm characteristics! */
sum prob_ipo_mlogit_late_Nhighvcst if late==0 & highvcst==1, d 
ttest prob_ipo_mlogit_early_Nhighvcst == prob_ipo_mlogit_late_Nhighvcst if late==0 & highvcst==1
/* Diff in diff t-test */
gen prob_ipo_mlogit_highvcst_diff=prob_ipo_mlogit_late_highvcst-prob_ipo_mlogit_early_highvcst if late==0
gen prob_ipo_mlogit_Nhighvcst_diff=prob_ipo_mlogit_late_Nhighvcst-prob_ipo_mlogit_early_Nhighvcst if late==0
ttest prob_ipo_mlogit_highvcst_diff == prob_ipo_mlogit_Nhighvcst_diff if late==0 & highvcst==1

/***********************************************************************************/
/***************** Multinomial Logit ma probabilities */
/* The following is the actual estimated probability for ma in early years for highvc_st_1_LRD */
sum prob_ma_mlogit_early_highvcst if late==0 & highvcst==1, d 
/* The following is the hypothetical estimated probability for ma in late years for highvc_st_1_LRD using early-year highvc_st_1_LRD firm characteristics! */
sum prob_ma_mlogit_late_highvcst if late==0 & highvcst==1, d 
ttest prob_ma_mlogit_early_highvcst == prob_ma_mlogit_late_highvcst if late==0 & highvcst==1
/* The following is the hypothetical estimated probability for ma in early years for Nhighvc_st_1_LRD using early-year highvc_st_1_LRD firm characteristics! */
sum prob_ma_mlogit_early_Nhighvcst if late==0 & highvcst==1, d 
/* The following is the hypothetical estimated probability for ma in late years for Nhighvc_st_1_LRD using early-year highvc_st_1_LRD firm characteristics! */
sum prob_ma_mlogit_late_Nhighvcst if late==0 & highvcst==1, d 
ttest prob_ma_mlogit_early_Nhighvcst == prob_ma_mlogit_late_Nhighvcst if late==0 & highvcst==1
/* Diff in diff t-test */
gen prob_ma_mlogit_highvcst_diff=prob_ma_mlogit_late_highvcst-prob_ma_mlogit_early_highvcst if late==0
gen prob_ma_mlogit_Nhighvcst_diff=prob_ma_mlogit_late_Nhighvcst-prob_ma_mlogit_early_Nhighvcst if late==0
ttest prob_ma_mlogit_highvcst_diff == prob_ma_mlogit_Nhighvcst_diff if late==0 & highvcst==1

/******************************************************************/
/***************** Panel G: High/Low VCFracInd Firms *********************************************/

xi: mlogit exit $control i.year if late==0 & highvcnaics3==1, base(0)  
predict prob_ipo_mlogit_early_highvcind, pr outcome(2)
predict prob_ma_mlogit_early_highvcind, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highvcnaics3==1, base(0)  
predict prob_ipo_mlogit_late_highvcind, pr outcome(2)
predict prob_ma_mlogit_late_highvcind, pr outcome(1)
xi: mlogit exit $control i.year if late==0 & highvcnaics3==0, base(0)  
predict prob_ipo_mlogit_early_Nhighvcind, pr outcome(2)
predict prob_ma_mlogit_early_Nhighvcind, pr outcome(1)
xi: mlogit exit $control i.year if late==1 & highvcnaics3==0, base(0)  
predict prob_ipo_mlogit_late_Nhighvcind, pr outcome(2)
predict prob_ma_mlogit_late_Nhighvcind, pr outcome(1)

/***********************************************************************************/
/***************** Multinomial Logit IPO probabilities */
/* The following is the actual estimated probability for IPO in early years for highvc_naic3_1_LRD */
sum prob_ipo_mlogit_early_highvcind if late==0 & highvcnaics3==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for highvc_naic3_1_LRD using early-year highvc_naic3_1_LRD firm characteristics! */
sum prob_ipo_mlogit_late_highvcind if late==0 & highvcnaics3==1, d 
ttest prob_ipo_mlogit_early_highvcind == prob_ipo_mlogit_late_highvcind if late==0 & highvcnaics3==1
/* The following is the hypothetical estimated probability for IPO in early years for Nhighvc_naic3_1_LRD using early-year highvc_naic3_1_LRD firm characteristics! */
sum prob_ipo_mlogit_early_Nhighvcind if late==0 & highvcnaics3==1, d 
/* The following is the hypothetical estimated probability for IPO in late years for Nhighvc_naic3_1_LRD using early-year highvc_naic3_1_LRD firm characteristics! */
sum prob_ipo_mlogit_late_Nhighvcind if late==0 & highvcnaics3==1, d 
ttest prob_ipo_mlogit_early_Nhighvcind == prob_ipo_mlogit_late_Nhighvcind if late==0 & highvcnaics3==1
/* Diff in diff t-test */
gen prob_ipo_mlogit_highvcind_diff=prob_ipo_mlogit_late_highvcind-prob_ipo_mlogit_early_highvcind if late==0
gen prob_ipo_mlogit_Nhighvcind_diff=prob_ipo_mlogit_late_Nhighvcind-prob_ipo_mlogit_early_Nhighvcind if late==0
ttest prob_ipo_mlogit_highvcind_diff == prob_ipo_mlogit_Nhighvcind_diff if late==0 & highvcnaics3==1

/***********************************************************************************/
/***************** Multinomial Logit ma probabilities */
/* The following is the actual estimated probability for ma in early years for highvc_naic3_1_LRD */
sum prob_ma_mlogit_early_highvcind if late==0 & highvcnaics3==1, d 
/* The following is the hypothetical estimated probability for ma in late years for highvc_naic3_1_LRD using early-year highvc_naic3_1_LRD firm characteristics! */
sum prob_ma_mlogit_late_highvcind if late==0 & highvcnaics3==1, d 
ttest prob_ma_mlogit_early_highvcind == prob_ma_mlogit_late_highvcind if late==0 & highvcnaics3==1
/* The following is the hypothetical estimated probability for ma in early years for Nhighvc_naic3_1_LRD using early-year highvc_naic3_1_LRD firm characteristics! */
sum prob_ma_mlogit_early_Nhighvcind if late==0 & highvcnaics3==1, d 
/* The following is the hypothetical estimated probability for ma in late years for Nhighvc_naic3_1_LRD using early-year highvc_naic3_1_LRD firm characteristics! */
sum prob_ma_mlogit_late_Nhighvcind if late==0 & highvcnaics3==1, d 
ttest prob_ma_mlogit_early_Nhighvcind == prob_ma_mlogit_late_Nhighvcind if late==0 & highvcnaics3==1
/* Diff in diff t-test */
gen prob_ma_mlogit_highvcind_diff=prob_ma_mlogit_late_highvcind-prob_ma_mlogit_early_highvcind if late==0
gen prob_ma_mlogit_Nhighvcind_diff=prob_ma_mlogit_late_Nhighvcind-prob_ma_mlogit_early_Nhighvcind if late==0
ttest prob_ma_mlogit_highvcind_diff == prob_ma_mlogit_Nhighvcind_diff if late==0 & highvcnaics3==1













